package top.yokey.shopnc.model;

import top.yokey.shopnc.base.BaseConstant;
import top.yokey.base.base.BaseHttpClient;
import top.yokey.base.base.BaseHttpListener;

import java.io.File;

@SuppressWarnings("ALL")
public class MemberRefundModel {

    private final String ACT = "member_refund";
    private static volatile MemberRefundModel instance;

    public static MemberRefundModel get() {
        if (instance == null) {
            synchronized (MemberRefundModel.class) {
                if (instance == null) {
                    instance = new MemberRefundModel();
                }
            }
        }
        return instance;
    }

    public void refundAllFrom(String orderId, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "refund_all_form")
                .add("order_id", orderId)
                .get(baseHttpListener);

    }

    public void getRefundList(String page, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "get_refund_list")
                .add("page", BaseConstant.PAGE)
                .add("curpage", page)
                .get(baseHttpListener);

    }

    public void uploadPic(File file, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "upload_pic")
                .add("refund_pic", file)
                .post(baseHttpListener);

    }

    public void getRefundInfo(String refundId, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "get_refund_info")
                .add("refund_id", refundId)
                .get(baseHttpListener);

    }

    public void refundForm(String orderId, String goodsId, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "refund_form")
                .add("order_id", orderId)
                .add("order_goods_id", goodsId)
                .get(baseHttpListener);

    }

    public void refundAllPost(String orderId, String message, String pic0, String pic1, String pic2, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "refund_all_post")
                .add("order_id", orderId)
                .add("buyer_message", message)
                .add("refund_pic[0]", pic0)
                .add("refund_pic[1]", pic1)
                .add("refund_pic[2]", pic2)
                .post(baseHttpListener);

    }

    public void refundPost(String orderId, String goodsId, String type, String reasonId, String amount, String message, String pic0, String pic1, String pic2, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "refund_post")
                .add("order_id", orderId)
                .add("order_goods_id", goodsId)
                .add("refund_type", type)
                .add("reason_id", reasonId)
                .add("refund_amount", amount)
                .add("buyer_message", message)
                .add("refund_pic[0]", pic0)
                .add("refund_pic[1]", pic1)
                .add("refund_pic[2]", pic2)
                .post(baseHttpListener);

    }

}
